<?php

use yii\helpers\Html;
use yii\widgets\LinkPager;
use yii\grid\GridView;
use yii\bootstrap\Modal;
use kartik\select2\Select2;

/**
 * @var yii\web\View $this
 * @var amnah\yii2\user\Module $module
 * @var array $actions
 */
global $regionTypes2;
global $prodAttrCodes;
$regionTypes2 = $regionTypes;
$module = $this->context->module;

$this->title = Yii::t('user', 'Yii 2 User');




$createUrlModel                     = [];
$createUrlModel['id']            =  'activity-create-sem-link';
$createUrlModel['class']        = 'btn btn-sm  btn-success activity-create-sem-link';
$createUrlModel['data-toggle'] = 'modal';
$createUrlModel['data-target'] = '#create-sem-modal';
$createUrlModel['label'] = '创建记录';
$createUrlModel['title'] = '创建新记录';
$createUrlModel ['data-last_url']         = $now_url;

$createUrlModelWx                     = [];
$createUrlModelWx['id']            =  'activity-create-sem-link';
$createUrlModelWx['class']        = 'btn btn-sm  btn-success activity-create-sem-link';
$createUrlModelWx['data-toggle'] = 'modal';
$createUrlModelWx['data-target'] = '#create-sem-modal';
$createUrlModelWx['label'] = '创建记录';
$createUrlModelWx['title'] = '创建新记录';
$createUrlModelWx ['data-last_url']         = $now_url;
$createUrlModelWx ['data-wx']         = 1;



?>


<section class="content-header">
    <h1>
        定制   <?= Html::encode($custom_name) ?> 列表视图
        <small>视图配置</small>
    </h1>
    <ol class="breadcrumb">
        <?php
        // 创建新的字段按钮
        echo Html::a( Html::tag('span', Yii::t('region', 'Create') .'微信数据' , ['class' => "glyphicon fa fa-plus-square"])    , '#',$createUrlModelWx ) ;
        ?>
        <?php
        // 创建新的字段按钮
        echo Html::a( Html::tag('span', Yii::t('region', 'Create') .'网络推广数据' , ['class' => "glyphicon fa fa-plus-square"])    , '#',$createUrlModel ) ;
        ?>
    </ol>
</section>





<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <input type="button" value="1735日推广数据" class="btn btn-lg btn-primary h1">&nbsp &nbsp
                    <input type="button" value="微信日推广数据" class="btn btn-lg btn-primary h2">

                    <div class="box-tools">
                        <div class="input-group input-group-sm" style="width: 150px;">


                        </div>
                    </div>
                </div>
                <div class="box-body bd1">
                    <div class="row">

                        <?php
                        echo    $this->render('index_context',
                            [
                                'now_url'  => $now_url,
                                'dataProvider' => $dataProvider,
                                'searchModel' =>  $searchModel]);

                        ?>

                    </div>
                </div>
                <div class="box-body bd2" style="display: none" >
                    <div class="row">

                        <?php
                        echo    $this->render('index_context2',
                            [
                                'now_url'  => $now_url,
                                'dataProvider' => $dataProvider,
                                'searchModel' =>  $searchModel]);

                        ?>


                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<?php
    $js = <<<JS
    jQuery('.activity-create-sem-link').on('click',function() {
    $('.document-nav-create-sem-form').remove();
    $.get(
    '/work/sem/create',
    {
    last_url: $(this).data('last_url'),
    wx: $(this).data('wx')
    },
    function (data) {
    $('#create-sem-modal').find('.modal-dialog').html(data);
    
    }
    );
    });
JS;
    $this->registerJs($js);

$js = <<<JS
    jQuery('.activity-update-sem-link').on('click',function() {
        $('.document-nav-create-sem-form').remove();
        $.get(
            '/work/sem/update',
            {
                id: $(this).data('id'),
                last_url: $(this).data('last_url'),
                wx: $(this).data('wx')
            },
            function (data) {
                $('#create-sem-modal').find('.modal-dialog').html(data);
            
            }
        );
    });
JS;
$this->registerJs($js);

$js = <<<JS
    jQuery('.h1').on('click',function() {
        $('.bd1').show();
        $('.bd2').hide();
    });
JS;
$this->registerJs($js);

$js = <<<JS
    jQuery('.h2').on('click',function() {
        $('.bd1').hide();
        $('.bd2').show();
    });
JS;
$this->registerJs($js);


    Modal::begin([
    'id' => 'create-sem-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title"> 创建网络推广</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
    'options' => [
    'tabindex' => false
    ],
    ]);
    Modal::end();






$js = <<<JS
    jQuery('.t').on('click',function() {
        console.log($(this).parent().parent().children().eq(0).html());
        $('.modal-body').empty();
        $.get(
            '/work/sem/url',
            {
                id: $(this).parent().parent().children().eq(0).html()

            },
            function (data) {
                //$('#black-list-modal').find('.modal-dialog').html(data);

                $('.modal-body').html(data['url']);
            }
        );
    });
JS;
$this->registerJs($js);

Modal::begin([
    'id' => 'black-list-modal',
    'class' => 'modal modal-primary',
    'header' => '<h4 class="modal-title">url</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>',
]);
Modal::end();

?>




